package vip.zhenzicheng.algorithm.leetcode.sort;

import vip.zhenzicheng.algorithm.sort.FastSort;
import vip.zhenzicheng.algorithm.sort.InsertSort;
import vip.zhenzicheng.algorithm.util.ArrayUtils;

/**
 * <a href="https://leetcode.cn/problems/sort-an-array/">排序数组 [中等]</a>
 * 提示：
 * 1 <= nums.length <= 5 * 104
 * -5 * 104 <= nums[i] <= 5 * 104
 *
 * @author zhenzicheng
 * @date 2022-06-10 09:35
 */
public class SortAnArray_912 {

  public static void main(String[] args) {
    int[] randomArray = ArrayUtils.getRandomArray(30, 50);
    sort(randomArray, 0, randomArray.length - 1);
    ArrayUtils.printArray(randomArray);
  }

  //
  public static void sort(int[] arr, int L, int R) {
    if (R - L < 15) { // 元素比较少时采用插入排序
      InsertSort.insertSort2(arr);
    } else {
      FastSort.fastSort(arr, L, R);
    }
  }

}
